/*
 * @Descripttion:
 * @Author: voanit
 * @Date: 2022-05-30 10:59:29
 * @LastEditors: voanit
 * @LastEditTime: 2022-05-30 11:10:57
 */

import axios from 'axios'
import { RootThunkAction } from '..'
export type newListItem = {
  art_id: string
  title: string
  aut_id: string
  comm_count: number
  pubdate: string
  aut_name: string
  is_top: number
  cover: {
    type: number
    images: string[]
  }
}
export type TypeNewListAction = {
  type: 'article/getArticleList'
  payload: newListItem[] //[{id:1,name:'jack'},{}]
}
export const getArticleList = (id: number): RootThunkAction => {
  return async (dispatch: any) => {
    const res = await axios.get(
      `http://geek.itheima.net/v1_0/articles?channel_id=${id}&timestamp=${Date.now()}`
    )
    dispatch({
      type: 'article/getArticleList',
      payload: res.data.data.results,
    })
  }
}
